<?php

/*
 * litchicms
 * Copyright (C) ${date} Author: tiefa(539247@qq.com)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
!defined('BRK') && exit("!");

if (!function_exists('Component_ui_pagevarset')) {

    function Component_ui_pagevarset($arr=FALSE) {
        !$arr && exit('Component_ui_pagevarset');

        $str = "";
        $all_pageset = brk_build_this_pageset_array(empty($arr['collection_value']) ? "" : $arr['collection_value']);
        if (is_array($all_pageset)) {
            foreach ($all_pageset as $value) {
                $str.="<tr>
                    <td>" . $value['diy_name'] . ":</td>
                    <td>" . input_text_control("pagevarset][" . $value['diy_key'], htmlspecialchars($value['diy_value']), 'pagevarset') . "</td>
                    </tr>";
            }
        } else {
            $str = "暂时没有该选项";
        }

        return "
    <div class='content_group_row'>
        <table class='thetable' border='0' cellpadding='0' cellspacing='1'>
            <tr>
                <td class='td1' bgcolor='#ffffff'>
                    <div>
                        <div class='cname'><b>页面域变量</b>:</div>
                        <div class='cdesc'>提供在频道和页面之间相同变量不同的值...默认不用理它</div>
                    </div>
                </td>
                <td class='td2' >
                    <div>


                      <div>
                            <input type=\"button\" value=\"显示\" id=\"show_upload_form\" onclick=\"show_hide_pagevarset(this)\" />
                      </div>
                      <div id=\"show_hide_pagevarset\" style=\"display:none\">
                            <table border='0' cellpadding='0' cellspacing='1'>
                                $str
                            </table>
                      </div>


                    </div>
                </td>
            </tr>
        </table>
    </div>
    ";
    }

}




if (!function_exists('Component_buildField_pagevarset')) {

    function Component_buildField_pagevarset() {
        return array('pagevarset' => empty($_POST['field']['pagevarset']) ? "" : addslashes(serialize(brk_stripslashes($_POST['field']['pagevarset']))));
    }

}